#pragma once
/*
@description: contain all contra data, variable,
init all default data of contra entity
@author: TriLVH
*/
#include "AbstractData.h"
#include "BulletContainer.h"

#define _DATA_CONTRA_STATE_IN_WATER 100
#define _DATA_CONTRA_STATE_ON_LAND 101
#define _DATA_CONTRA_STATE_LAND_WATER 102
#define _DATA_CONTRA_STATE_WATER_LAND 103
// Contra state
#define _STATE_CONTRA_NONE					0
#define _STATE_CONTRA_STAND_RIGHT			1
#define _STATE_CONTRA_MOVE_RIGHT			3
#define _STATE_CONTRA_FIRE_RIGHT			5
#define _STATE_CONTRA_FIRE_UP_RIGHT			7
#define _STATE_CONTRA_UP_RIGHT				9
#define _STATE_CONTRA_UP_CROSS_RIGHT		11
#define _STATE_CONTRA_FIRE_UP_CROSS_RIGHT	13
#define _STATE_CONTRA_SIT_RIGHT				15
#define _STATE_CONTRA_FIRE_SIT_RIGHT		17
#define _STATE_CONTRA_DOWN_CROSS_RIGHT		19
#define _STATE_CONTRA_FIRE_DOWN_CROSS_RIGHT	21
#define _STATE_CONTRA_FLY_RIGHT				23
#define _STATE_CONTRA_SWIM_RIGHT			25
#define _STATE_CONTRA_SWIM_RIGHT_FIRE		27
#define _STATE_CONTRA_STAND_LEFT			2
#define _STATE_CONTRA_MOVE_LEFT				4
#define _STATE_CONTRA_FIRE_LEFT				6
#define _STATE_CONTRA_FIRE_UP_LEFT			8
#define _STATE_CONTRA_UP_LEFT				10
#define _STATE_CONTRA_UP_CROSS_LEFT			12
#define _STATE_CONTRA_FIRE_UP_CROSS_LEFT	14
#define _STATE_CONTRA_SIT_LEFT				16
#define _STATE_CONTRA_FIRE_SIT_LEFT			18
#define _STATE_CONTRA_DOWN_CROSS_LEFT		20
#define _STATE_CONTRA_FIRE_DOWN_CROSS_LEFT	22
#define _STATE_CONTRA_FLY_LEFT				24
#define _STATE_CONTRA_SWIM_LEFT				26
#define _STATE_CONTRA_SWIM_LEFT_FIRE		28
#define _STATE_CONTRA_SWIM_DOWN				29
#define _STATE_CONTRA_SWIM_FIRE_UP_LEFT		30
#define _STATE_CONTRA_SWIM_FIRE_UP_RIGHT	31
#define _STATE_CONTRA_SWIM_FIRE_CROSS_LEFT	32
#define _STATE_CONTRA_SWIM_FIRE_CROSS_RIGHT	33
#define _STATE_CONTRA_DEAD					101

#define _FRAMERATE_CONTRA_DEFAULT 8
#define _DATA_CONTRA_UNDEAD 100

#define _DATA_CONTRA_WIDTH 30
#define _DATA_CONTRA_HEIGHT 75
#define _DATA_CONTRA_BULLET_1_DISTANCE_LIVE 600
#define _DATA_CONTRA_BULLET_1_DELAY 10
#define _DATA_CONTRA_BULLET_3_DELAY 10
#define _DATA_CONTRA_BULLET_1_MAX 4
#define _DATA_CONTRA_BULLET_2_MAX 8
#define _DATA_CONTRA_BULLET_3_MAX 8

#define _DATA_CONTRA_DELAY_INTERACT 20
#define _DATA_CONTRA_JUMPING_TIME 57

#define _DATA_CONTRA_TIME_DELAY_SHOOTING 25

class ContraData : public AbstractData {
protected:
	// Init contra sprite, the same with all entity, need rect data
	virtual void initSprite();
public:
	double deadx, deady;
	bool notMove;
	int undeadDelay;
	int delayInteractCounter;
	// jumping timecounter
	int jumpingTimeCounter;
	// delay shooting time
	int timeDelayShooting; 
	// ready to fly
	bool readyToFly;
	// contra body sprites
	Sprites* bodySprites;
	bool isSwimming;
	bool onJump;
	long updateTime, changeStateTime;
	/* Bullet container to manage contra bullet */
	BulletContainer* bulletContainer;
	// Constructor 
	ContraData(int id, double x, double y);

	// Initialzie Data
	// Init all other data
	virtual void initData();
	// Init sprite handler for sprite
	virtual void initSpriteHandler(LPD3DXSPRITE spriteHandler);
	// virtual void sprite get
	Sprites* getSprites();
	Sprites* getBodySprites() {
		return bodySprites;
	}

	// Check is moving
	bool checkIsMoving();

	bool checkCorrectState();

	// Check time delay shootting
	bool checkDelayShooting();

	// reset time delay shooting
	void resetTimeDelayShooting();

	// check contra flying
	bool checkIsFlying();

	virtual void updateData(ACTIONS action, int value);
};